package iserver

import (
	"src/zeus/linmath"
	"src/zeus/msgdef"
)

// ISpaceEntity 代表空间中的一个实体
type ISpaceEntity interface {
	IEntity
	IPos
	IClientBroadcaster
	IAOIEntity
	GetSpace() ISpace
	SetClient(ISess)

	AddExtWatchEntity(o ICoordEntity, isUpdate2BeWatcher bool)

	SetDelay(d uint8)
	GetDelay() uint8
	//IEntrustEntity
}

// // ISpaceEntityPropsGetter 获取属性数据
// type ISpaceEntityPropsGetter interface {
// 	GetAOIProp() msgdef.IMsg
// }

// IPos 拥有位置信息的接口
type IPos interface {
	//设置坐标带操作
	SetPos(pos linmath.Vector3)
	GetPos() linmath.Vector3
	//直接设置坐标
	GetPosition() *linmath.Vector3
	SetPosition(v *linmath.Vector3)
	SetRota(int32)
	GetRota() int32
	//获取半径
	GetModelRadius() float32
}

/*
// IPosValidate 位置验证
type IPosValidate interface {
	IsPosValid(linmath.Vector3) bool
}
*/

// IPosChange 位置变化回调
type IPosChange interface {
	OnPosChange(curPos, origPos linmath.Vector3)
}

// IMover 寻路移动能力
type IMover interface {
	SetSpeed(speed float32)
	Move(destPos linmath.Vector3) bool
	StopMove()
	IsMoving() bool

	PauseNav()
	ResumeNav()
}

//
/*
IClientBroadcaster AOI广播
都帧尾才发消息
*/
type IClientBroadcaster interface {
	//在帧尾给所有看到我的人发
	CastMsgToAllClient(msgdef.IMsg)
	//是帧尾给自己发消息
	CastMsgToMe(msgdef.IMsg)
	//是帧尾给自己发消息
	CastMsgToMeRaw([]byte)
	//在帧尾给所有看到我的人发，除了自己
	CastMsgToAllClientExceptMe(msgdef.IMsg)
	//在帧尾给指定半径的人发，除了自己
	CastMsgToRangeExceptMe(center *linmath.Vector3, radius int, msg msgdef.IMsg)
	//在帧尾给指定半径的人发，包括目标半径
	CastMsgToRange(center *linmath.Vector3, radius int, msg msgdef.IMsg)
	//在帧尾给指定半径的人发，除了自己
	CastMsgToCenterExceptMe(center *linmath.Vector3, radius int, msg msgdef.IMsg)
	//在帧尾给指定半径的人发
	CastMsgToCenter(center *linmath.Vector3, radius int, msg msgdef.IMsg)
	CastRPCToAllClient(methodName string, args ...interface{})
	CastRPCToMe(methodName string, args ...interface{})
	CastRPCToAllClientExceptMe(methodName string, args ...interface{})
}

// IAOIEntity  AOI实体类型查询
type IAOIEntity interface {
	IsWatcher() bool
	// 获取AOI系统中需要知道的主人ID
	GetAOIOwnerUID() uint64
	// IsMarker() bool
}

// IEntrustEntity 委托对象
type IEntrustEntity interface {
	GetID() uint64
	GetRealPtr() interface{}
	EntrustToTarget(IEntrustEntity)
	GetEntrustTarget() IEntrustEntity
	UnEntrust()
	IsEntrusted() bool
	EntrustUpdateSate(msg *msgdef.SyncUserState)
	EntrustedBy(IEntrustEntity)
	UnEntrustedBy(IEntrustEntity)
	IsBeEntrusted() bool
}

// IEntrustedRPCCaller 调用被委托对象的RPC方法
type IEntrustedRPCCaller interface {
	EntrustedRPC(msg *msgdef.RPCMsg)
}
